package chai.ningning.myself;

public class Page123 {

    static class MyThread implements Runnable{
        @Override
        public void run() {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName()+"运行到第"+i+"次");
            }
        }
    }

    public static void main(String[] args) {
        Thread.currentThread().setName("主线程");

        Runnable a = new MyThread();
        Thread t = new Thread(a);// Thread t = new Thread(new MyThread());
        t.setName("子线程");
        t.start();

        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName()+"运行到第"+i+"次");
        }
    }
}
